// components/grid/index.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        list: Array,
        fullScreen: {
            type: Boolean,
            value: false
        },
        big: {
            type: Boolean,
            value: false
        },
        num: {
            type: Number,
            value: 5
        },
        data: {
            type: Object,
            value: null
        },
        mescount:Number
    },

    /**
     * 组件的初始数据
     */
    data: {},

    /**
     * 组件的方法列表
     */
    methods: {
        gridClick: function(e) {
            let { index } = e.currentTarget.dataset
            let data = this.data.list[index];
            if(!wx.getStorageSync('userInfo')) {
                wx.reLaunch({
                    url: '/pages/login/index'
                })
                return;
            }
            if (data.type === 'phone') {
                wx.makePhoneCall({
                    phoneNumber: data.path
                })
            } else 
            if(data.title == '同城互动') {
                wx.setNavigationBarColor({
                    frontColor: '#000000',
                    backgroundColor: '#fff'
                })
                wx.redirectTo({
                    url: '/pages/index/index?interactive='+'interactive'
                })
                // let tabbarConf = this.data.tabbarConf
                // tabbarConf[url].loaded = true
                // this.setData({
                //     activeUrl: url,
                //     tabbarConf
                // })
              
            } else if (data.data != null) {
                wx.redirectTo({
                    url:
                        this.data.list[index].path +
                        '?data=' +
                        JSON.stringify(data.data)
                })
            } else {
                wx.redirectTo({
                    url: this.data.list[index].path
                })
            }
        }
    }
})
